package com.tenton.netty.unicast.server;

import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;
import io.netty.channel.socket.DatagramPacket;

import java.nio.charset.StandardCharsets;

/**
 * @ClassName： UnicastServerHandler
 * @Description： 单播服务端解析
 * @Author： tangdong
 * @Date： 2024/7/4 09:38
 */
public class UnicastServerHandler extends SimpleChannelInboundHandler<DatagramPacket> {
    @Override
    protected void channelRead0(ChannelHandlerContext channelHandlerContext, DatagramPacket msg) throws Exception {
        ByteBuf byteBuf = msg.content();
        String s = byteBuf.toString(StandardCharsets.UTF_8);
        System.out.println("接收发送消息：" + s);
    }
}
